<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <style>
    ul {
        list-style-type: none;
        cursor: pointer;
    }
    </style>
    <title>Self defined attribute</title>
</head>
<body>
    <ul>

        <li >Carl</li>
        <li >John</li>
        <li >Machel</li>
        <li >Tom</li>
        <li >Suci</li>
    </ul>

    <script>
        // 在 HTML 中创建的自定义属性，如果要获取这个属性的值
        // 需要用到 getAttribute("属性的名字")
        var list = document.getElementsByTagName("li");
        for (i=0; i<list.length; i++){
            // Set attribute
            list[i].setAttribute("score", (i+1)*10);

            // Get attribute
            list[i].onclick = function(){
                alert(this.getAttribute("score"));
            };
        };
    </script>
</body>
</html>